class SentEmail < ActiveRecord::Base
  belongs_to :contact
  belongs_to :newsletter
  
  before_create :set_sent_by
  
  def set_sent_by
    self.sent_by = self.sent_by || ENV['USER']
  end
  
  # Only allow save when creating; further updates are not allowed.
  alias old_save save
  def save
    raise Exception, "Cannot update a SentEmail" unless self.new_record?
    old_save
  end
end
